# Maintainer: Adrian Pop <adrian.pop@liu.se>

_realname=uasm
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=2.56.2
pkgrel=1
pkgdesc="UASM is a free MASM-compatible assembler based on JWasm (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
license=('Watcom-1.0')
url="https://github.com/Terraspace/UASM"
depends=("${MINGW_PACKAGE_PREFIX}-cc")
source=("https://github.com/Terraspace/UASM/archive/v${pkgver}.tar.gz")
sha256sums=('a624cf17cce9b11155aebb5b954b2a6d93052d7e2857284ba087c546442b5eeb')

prepare() {
  cd ${srcdir}/UASM-${pkgver}
  rm -rf MinGWR
  sed -i -e 's/^extra_c_flags = .*$/& -Wno-int-conversion/' GccWin.mak
  sed -i -e 's|gcc\.exe|cc.exe|g' GccWin.mak
}

build() {
  cd ${srcdir}/UASM-${pkgver}/
  make -f GccWin.mak
}

package() {
  install -Dm744 ${srcdir}/UASM-${pkgver}/MinGWR/hjwasm.exe "${pkgdir}${MINGW_PREFIX}/bin/jwasm.exe"
  install -Dm744 ${srcdir}/UASM-${pkgver}/MinGWR/hjwasm.exe "${pkgdir}${MINGW_PREFIX}/bin/${_realname}.exe"
  install -Dm644 ${srcdir}/UASM-${pkgver}/License.txt "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE"
}
